import random
l1=['包乐尔夫','陈丹','耿文俊','李梦佳','屈润利','田翊扬','王佳龙','王仲媛','张银晗','胡康成','林子祺']
[(0,''),(1,'')]
l2=[0,0,0,0,0,0,0,0,0,0,0]
l3=[]
n=len(l1)
# for i in range(n-1):
#     l2[i]=0
#分配第k个红包中的金额
def redEnv(k,rest):
    m=round(random.uniform(0.01,rest),2)
    return m


# def seconde_min(lt):
#     d={}         #设定一个空字典
#     for i, v in enumerate(lt):#利用函数enumerate列出lt的每个元素下标i和元素v
#         d[v]=i   #把v作为字典的键，v对应的值是i
#     lt.sort()    #运用sort函数对lt元素排
#     y=lt[1]      #此时lt中第二小的下标是6，求出对应的元素就是字典对应的键
#     return d[y]  #根据键找到对应值就是所找的下标


class Member:
    def __init__(self,total=0,payment=0,name=' '):
        self.total=total
        self.payment=payment
        self.name=name
        self.__num=5

    def get_num(self):
        return self.__num

    def divide(self,payment=0):
        m=self.get_num()
        print("从类中找到的私有成员 “红包个数”为：")
        print(m)
        for i in range(m-1):
            cho=random.randint(0,len(l1)-1)
           # print("oo",cho)
            while cho in l3:
                #print(cho)
                cho = random.randint(0, len(l1)-1)
            #if cho not in l3:
          #  print("ok",cho)
            l3.append(cho)
            #print(l3)
            l2[cho]=redEnv(i,payment)
            while payment-l2[cho]<0.01*(m-i):
                l2[cho] = redEnv(i, payment)
            payment-=l2[cho]
          #  print("qq",l2[cho])
         #   print("ll",payment)
          #  print(l2[cho])
        tem=random.randint(0,len(l1)-1)

        #print("po",payment)
        print(l3)  #存储抢到红包的人
        while tem  in l3:
            tem=random.randint(0,len(l1)-1)
        #print("ssss", tem)
        l2[tem]=round(payment,2)
        del l3[-len(l3):]

#l4实例成员列表
l4=[]
for k in range(11):
    stu=Member(10,5)
    l4.append(stu)
for m in range(11):
    l4[m].name=l1[m]

# a=Member(10,5)
# a.divide(5)
for p in range(11):
    l4[p].divide(5)
print("经过抢红包之后，红包金额的分布情况为：")
print(l1)
print(l2)
# for k in range(6):
#     l2.remove(0)
# print(l2)
print("运气王为：",end='\t')
for i in range(11):
    if l2[i]==max(l2):
        print(l1[i])
# print("倒霉蛋是：",end='\t')
# print(l1[seconde_min(l2)])
print("倒霉蛋是：",end='\t')
for j in range(11):
    if l2[j]==min(l2):
        print(l1[j])
print("没抢到红包的有：")
for q in range(11):
    if l2[q]==0:
        print(l1[q])
